package cj.web.kly.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.kly.domain.GroupDep;

/**
 * 
 * @author 
 *
 */
@DAO
public interface GroupDepDAO{
	
	@SQL("SELECT * FROM GroupDep WHERE deleteFlag=1 AND groupId=:1 ORDER BY orderNo ")
    List<GroupDep> queryByGroupId(int groupId);
	
	@SQL("SELECT * FROM GroupDep WHERE deleteFlag=1 #if(:t.name != null){ AND name LIKE '%##(:t.name)%' } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<GroupDep> query(@SQLParam("t") GroupDep groupDep);
		
	@SQL("SELECT count(1) FROM GroupDep WHERE deleteFlag=1 #if(:t.name != null){ AND name LIKE '%##(:t.name)%' } ")
    int querySize(@SQLParam("t") GroupDep groupDep);
    
    @SQL("select * from GroupDep where id=:1 ")
    GroupDep queryById(int id);
    
    @SQL("INSERT INTO GroupDep (groupId,name,cssName,carouselImage,duties,achievements,link,url,orderNo,deleteFlag,createUser,createAt,updateUser,updateAt) VALUES (:t.groupId,:t.name,:t.cssName,:t.carouselImage,:t.duties,:t.achievements,:t.link,:t.url,:t.orderNo,1,:t.createUser,now(),:t.updateUser,now()) ")
    void create(@SQLParam("t") GroupDep groupDep);
	
	@SQL("UPDATE GroupDep SET groupId=:t.groupId,name=:t.name,cssName=:t.cssName,carouselImage=:t.carouselImage,duties=:t.duties,achievements=:t.achievements,link=:t.link,url=:t.url,orderNo=:t.orderNo,updateUser=:t.updateUser,updateAt=now() WHERE id=:t.id ")
    void update(@SQLParam("t") GroupDep groupDep);
    
    @SQL("UPDATE GroupDep SET deleteFlag=0 WHERE id=:1 ")
    void deleteById(int id);
}